<template>
  <div>
    <div class="container">
      <div class="nav">
        <el-aside width="200px">
          <el-menu
            :default-active="$route.path"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-submenu index="/home">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>首页</span>
              </template>
              <el-menu-item-group>
                <template slot="title">用户管理</template>
                <el-menu-item index="/home/user" @click="toUser"
                  >普通用户</el-menu-item
                >
                <el-menu-item index="/home/admin" @click="toAdmin"
                  >管理员用户</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="/home">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>宠物信息</span>
              </template>
              <el-menu-item-group>
                <template slot="title">宠物管理</template>
                <el-menu-item index="/home/pets/dog" @click="toPets_dog"
                  >小狗</el-menu-item
                >
                <el-menu-item index="/home/pets/cat" @click="toPets_cat"
                  >小猫</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-menu-item index="3">
              <i class="el-icon-document"></i>
              <span slot="title">宠物领养信息/待办</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">宠物挂失/认领</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
      </div>
      <div class="content">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: null,
    };
  },
  methods: {
    toUser() {
      this.$router.push(
        { path: "/home/user" },
        () => {},
        () => {}
      );
    },
    toAdmin() {
      this.$router.push(
        { path: "/home/admin" },
        () => {},
        () => {}
      );
    },
    toPets_dog() {
      this.$router.push(
        { path: "/home/pets/dog" },
        () => {},
        () => {}
      );
    },
    toPets_cat() {
      this.$router.push(
        { path: "/home/pets/cat" },
        () => {},
        () => {}
      );
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style scoped src="../assets/reset.css">
</style>
<style lang="scss" scoped>
.container {
  .el-aside {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background-color: #545c64;
  }
  .content {
    position: absolute;
    top: 0;
    left: 200px;
    bottom: 0;
    right: 0;
  }
}
</style>